package LeetCode;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author Kechelle
 * @Date 2020/9/11 21:00
 * @Version 1.0
 */
public class Code53 {
    public static int maxSubArray(int[] nums) {
        int sum = 0;    //定义累加和
        int max = nums[0];   //和的最大值
        for (int num:nums){
            if (sum+num>=num){
                sum = sum + num;
            }else {
                sum = num;
            }
            if (max<sum){
                max = sum;
            }
        }
        return max;
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    throw new RuntimeException();
                }
                System.out.print("2");
            }
        });
        thread.start();
        thread.join();
        System.out.println("1");
    }
}
